<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('盘点列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <!--<div class="row">-->
            <!--<div class="col-sm-12 search-collapse">-->
                <!--<form id="formId">-->
                    <!--<div class="select-list">-->
                        <!--<ul>-->
                            <!--<li>-->
                                <!--<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>-->
                                <!--<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>-->
                            <!--</li>-->
                        <!--</ul>-->
                    <!--</div>-->
                <!--</form>-->
            <!--</div>-->

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="addInventory()" shiro:hasPermission="inventory:inventoryAll:add">
                    <i class="fa fa-plus"></i> 发起盘点
                </a>
                <!--<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="inventory:inventory:edit">-->
                    <!--<i class="fa fa-edit"></i> 修改-->
                <!--</a>-->
                <!--<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="inventory:inventory:remove">-->
                    <!--<i class="fa fa-remove"></i> 删除-->
                <!--</a>-->
                <!--<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="inventory:inventory:export">-->
                    <!--<i class="fa fa-download"></i> 导出-->
                 <!--</a>-->
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var sUserAgent = navigator.userAgent.toLowerCase();
        var bIsIpad = sUserAgent.match(/ipad/i) == 'ipad';
        var bIsIphone = sUserAgent.match(/iphone os/i) == 'iphone os';
        var bIsMidp = sUserAgent.match(/midp/i) == 'midp';
        var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == 'rv:1.2.3.4';
        var bIsUc = sUserAgent.match(/ucweb/i) == 'web';
        var bIsCE = sUserAgent.match(/windows ce/i) == 'windows ce';
        var bIsWM = sUserAgent.match(/windows mobile/i) == 'windows mobile';
        var bIsAndroid = sUserAgent.match(/android/i) == 'android';
        var isNotPc;
        if(bIsIpad || bIsIphone || bIsMidp || bIsUc7 || bIsUc || bIsCE || bIsWM || bIsAndroid ){
            isNotPc = true
            $("#toolbar").hide();
        }else{
            isNotPc = false
        }
        var prefix = ctx + "inventory/inventory";
        var endFlag = [[${@permission.hasPermi('inventory:inventoryAll:end')}]];

        $(function() {
            var options = {
                url: prefix + "/inventoryAllList",
                modalName: "盘点汇总",
                updateUrl: prefix + "/inventoryAllEdit/{id}",
                sortName:"createTime",
                sortOrder:"desc",
                height:520,
                columns: [
                    {
                        field : 'id',
                        title : '盘点编号'
                    },
                 {
                     field : 'createByName',
                     title : '发起人'
                 },
                    {
                        title : '是否结束',
                        formatter: function (value, row, index) {
                            return row.status==0?'未结束':'已结束';
                        }
                    },
                    {
                        field : 'createTime',
                        title : '发起时间',
                        sortable:true
                    },{
                        title: '操作',
                        align: 'left',
                        formatter: function(value, row, index) {
                            var actions = [];
                            actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="showAll(\'' + row.id + '\',\'' + row.createTime + '\')"><i class="fa fa-edit"></i>查看</a> ');
                            if(row.status==0){
                                actions.push('<a class="btn btn-success btn-xs ' + endFlag + '" href="javascript:void(0)" onclick="inventoryAllEdit(\'' + row.id + '\')"><i class="fa fa-edit"></i>结束盘点</a> ');
                            }
                            return actions.join('');
                        }
                }]
            };
            $.table.init(options);
        });
        function addInventory() {
            $.modal.confirm("确定发起盘点？",function () {
                $.operate.post(prefix + "/inventoryAllAdd");
            });
        }
        function inventoryAllEdit(id) {
            $.modal.confirm("确定结束盘点？",function () {
                $.operate.post(prefix + "/inventoryAllEdit",{id:id});
            })
        }
        function showAll(id,createTime) {
            var date = new Date(createTime);
            createTime=date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
            $.modal.openTab(createTime+"盘点",prefix + "/inventoryAll/"+id);
        }
    </script>
</body>
</html>